home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Tool Chest / Interfaces / MPW Interfaces / CIncludes / ErrMgr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-17  |  4.3 KB  |  113 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ErrMgr.h
  3.  
  4.     Copyright:    © 1983-1993 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Version:    System 7.1 for ETO #11
  8.     Created:    Tuesday, March 30, 1993 18:00
  9.  
  10. */
  11.  
  12. #ifndef __ERRMGR__
  13. #define __ERRMGR__
  14.  
  15. #ifndef __TYPES__
  16. #include <Types.h>
  17. #endif
  18.  
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. extern void InitErrMgr(char *toolErrFilename,char *sysErrFilename,Boolean showToolErrNbrs);
  23. /*
  24.     ErrMgr initialization.This must be done before using any other ErrMgr
  25.     routine.  Set showToolErrNbrs to true if you want all tool messages to contain
  26.     the error number following the message text enclosed in parentheses (e.g.,
  27.     "<msg txt> ([OS] Error <n>)"; system error messages always contain the error
  28.     number).  The toolErrFileName parameter is used to specify the name of a
  29.     tool-specific error file, and should be the NULL or a null string if not used
  30.     (or if the tool's data fork is to be used as the error file, see
  31.     GetToolErrText for futher details). The sysErrFileName parameter is used to
  32.     specify the name of a system error file, and should normally be the NULL or a
  33.     null string, which causes the ErrMgr to look in the MPW Shell directory for
  34.     "SysErrs.Err" (see GetSysErrText).
  35.     
  36.     If InitErrMgr is NOT called prior to calling GetSysErrText or GetToolErrText,
  37.     then those routines, the first time they are called, will call InitErrMgr as
  38.     InitErrMgr(NULL, NULL, true).
  39.     
  40.     The following global may be set to true to allow a C caller to process all
  41.     strings as Pascal strings:*/
  42.     
  43.     extern Boolean pascalStrings;    /* set to true for Pascal strings*//*
  44.     
  45.     This should be set PRIOR to calling InitErrMgr.  Once set, ALL strings, both
  46.     those passed to the ErrMgr as filenames and error message inserts, as well as
  47.     the messages returned by the ErrMgr will be Pascal strings.  There is NO
  48.     guarantee a '\0' byte is at the end of the string.    Results are unpredictable
  49.     if pascalStringsis set false after it has been set true!
  50.     
  51. */
  52.  
  53. extern void CloseErrMgr(void);
  54. /*
  55.     Ideally a CloseErrMgr should be done at the end of execution to make sure all
  56.     files opened by the ErrMgr are closed.    You can let normal program termination
  57.     do the closing.  But if you are a purist...
  58. */
  59.  
  60. extern char *GetSysErrText(short msgNbr,char *errMsg);
  61. /*
  62.     Get the error message text corresponding to system error number errNbr from
  63.     the system error message file (whose name was specified in the InitErrMgr
  64.     call).    The text of the message is returned in errMsg and the function returns
  65.     a pointer to errMsg.  The maximum length of the message is limited to 254
  66.     characters.
  67.     
  68.     Note, if a system message filename was not specified to InitErrMgr, then the
  69.     ErrMgr assumes the message file contained in the file "SysErrs.Err".  This
  70.     file is first accessed as "{ShellDirectory}SysErrs.Err" on the assumption that
  71.     SysErrs.Err is kept in the same directory as the MPW Shell.  If the file
  72.     cannot be opened, then an open is attempted on "SysErrs.Err" in the System
  73.     Folder.
  74. */
  75.  
  76. extern char *GetToolErrText(short msgNbr,char *errInsert,char *errMsg); 
  77. /*
  78.     Get the error message text corresponding to tool error number errNbr from
  79.     the tool error message file (whose name was specified in the InitErrMgr
  80.     call).    The text of the message is returned in errMsg and the function returns
  81.     a pointer to errMsg.  The maximum length of the message is limited to 254
  82.     characters.  If the message is to have an insert, then ErrInsert should be a
  83.     pointer to it.    Otherwise it should be either be a null string or a NULL
  84.     pointer.
  85.     
  86.     Inserts are indicated in error messages by specifying a '^' to indicate where
  87.     the insert is to be placed.
  88.     
  89.     Note, if a tool message filename was not specified to InitErrMgr, then the
  90.     ErrMgr assumes the message file contained in the data fork of the tool calling
  91.     the ErrMgr.  This name is contained in the Shell variable {Command} and the
  92.     value of that variable is used to open the error message file.
  93. */
  94.  
  95. extern void AddErrInsert(unsigned char *insert,unsigned char *msgString);
  96. /*
  97.     Add another insert to an error message string.This call is used when more
  98.     than one insert is to be added to a message (because it contains more than
  99.     one '^' character).
  100. */
  101.  
  102. extern unsigned char *addInserts(unsigned char *msgString,unsigned char *insert,
  103.     ... );
  104. /*
  105.     Add a set of inserts to an error message string.  AddErrInsert is called for
  106.     each insert parameter specified.
  107. */
  108. #ifdef __cplusplus
  109. }
  110. #endif
  111.  
  112. #endif
  113.